//by hbs
#include <bits/stdc++.h>
using namespace std;

#define N 100010

int n,m,a[N],q[N];

inline int rd()
{
    register int f=1,m=0;
    register char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
        m=(m<<3)+(m<<1)+(ch^48);
        ch=getchar();
    }
    return f*m;
}

int main()
{
    //remember to clear when the number is removed
    freopen("arena.in", "r", stdin);
    freopen("arena.out", "w", stdout);
    n=rd();
    m=rd();
    for(int i=1;i<=n;++i)
        a[i]=rd();
    for(int j=1;j<=m;++j)
        q[j]=rd();
    int k=log2(n);
    int k2=1;
    for(int i=1;i<=k;++i)
        k2*=2;
    if(k2<n)
        ++k;
    for(int i=1;i<=k;++i)
    {
        string s;
        cin>>s;
    }
    int T=rd();
    for(int i=1;i<=T;++i)
        printf("0\n");
    return 0;
}